package com.qupai.controller.auction;


import com.qupai.domain.dto.AuctionDTO;
import com.qupai.domain.dto.AuctioneerDTO;
import com.qupai.domain.dto.AuctioneerLoginDTO;
import com.qupai.domain.entity.Auctioneer;
import com.qupai.domain.result.Result;
import com.qupai.domain.vo.AuctioneerLoginVO;
import com.qupai.domain.vo.AuctioneerVO;
import com.qupai.service.IAuctioneerService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 拍卖师表，存储拍卖师信息 前端控制器
 * </p>
 *
 * @author bluefoxyu
 * @since 2024-07-30
 */
@RestController
@RequestMapping("/auction/auctioneer")
@Slf4j
@Tag(name = "志愿-拍卖师相关接口")
public class AuctioneerController {
    @Resource
    private IAuctioneerService auctioneerService;

    @Operation(summary = "拍卖师登录")
    @PostMapping("/login")
    public Result<AuctioneerLoginVO> login(@RequestBody AuctioneerLoginDTO auctioneerLoginDTO) {
        return Result.success(auctioneerService.login(auctioneerLoginDTO));
    }

    @PostMapping("/logout")
    @Operation(summary = "拍卖师退出登录，调用时前端删除token")
    public Result<String> logout() {
        return Result.success("拍卖师退出登录成功");
    }

    @GetMapping("/info")
    @Operation(summary = "查询个人信息")
    public Result<AuctioneerVO> info()
    {
        return Result.success(auctioneerService.info());
    }


    //TODO 用户名不能被修改
    @PostMapping("/update")
    @Operation(summary = "修改个人信息")
    public Result update(@RequestBody AuctioneerDTO auctionDTO)
    {
        auctioneerService.update(auctionDTO);
        return Result.success();
    }
}
